
public class Cave {
    private String name ;

    public synchronized void go() {
        String name = Thread.currentThread().getName();
        System.out.println(name+"正在通过"+this.name+"山洞，预计需要5s");
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public Cave(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


}
